<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        ul {
            list-style: none;
        }

        /* 图片410 * 170  */
        .wrapper {
            width: 600px;
            margin: 0 auto;
            overflow: hidden;
        }

        .wrapper .section .move {
            width: 3050px;
            position: relative;
            /* right: 10px; */
        }


        .wrapper .section .photo {
            float: left;
        }

        .wrapper .section .photo img {
            width: 600px;
            height: 220px;
        }

        .wrapper .section .menu ul {
            position: fixed;
            width: 600px;
            background-color: rgba(227, 226, 226, 0.5);
            top: 190px;
        }

        .wrapper .section .menu ul li {
            width: 120px;
            height: 30px;
            float: left;
            font-size: 7px;
            text-align: center;
            line-height: 30px;
        }

        .active {
            background-color: rgb(247, 246, 246);
        }
    </style>
    <script src="../js/jquery.min.js"></script>
    <script>
        $(function () {
            // 轮播图
            // 封装函数用来回调
            function fn() {
                index++;
                if (index == 5) {
                    index = 0;
                }
                console.log(index);
                $(".move").animate({
                    "left": -(index * 600)
                })
                $(".wrapper .menu ul li").eq(index).addClass("active").siblings("li").removeClass("active")
            }

            var index = 0;
            var timer = null;
            timer = setInterval(fn, 1000)

            // 进入盒子取消定时器
            $(".wrapper ").mouseenter(function () {
                clearInterval(timer)
            })

            // 移出盒子开启定时器
            $(".wrapper").mouseleave(function () {
                console.log(111);
                timer = setInterval(fn, 1000)

            })

            // 点击切换对应的图片 
            $(".wrapper .menu ul li").click(function () {
                index = $(this).index();
                console.log(index);
                $(this).addClass("active").siblings("li").removeClass("active");
                $(".move").stop().animate({
                    "left": -(index * 600)
                })
            })

        })
    </script>
</head>

<body>

    <div class="wrapper">
        <div class="section">
            <div class="move">
                <div class="photo">
                    <img src="./images/1.jpg" alt="">
                </div>
                <div class="photo">
                    <img src="./images/2.jpg" alt="">
                </div>
                <div class="photo">
                    <img src="./images/3.jpg" alt="">
                </div>
                <div class="photo">
                    <img src="./images/4.jpg" alt="">
                </div>
                <div class="photo">
                    <img src="./images/5.jpg" alt="">
                </div>
            </div>
            <div class="menu">
                <ul>
                    <li class="active">银河太空秘宝</li>
                    <li>魔女 婕拉 至臻</li>
                    <li>2020LPL春季赛季后赛</li>
                    <li>创世魔神2020</li>
                    <li>每周限时优惠</li>
                </ul>
            </div>
        </div>
    </div>
</body>

</html>